<!--
  This file is a part of the open-eBackup project.
  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
  If a copy of the MPL was not distributed with this file, You can obtain one at
  http://mozilla.org/MPL/2.0/.
  
  Copyright (c) [2024] Huawei Technologies Co.,Ltd.
  
  THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
  EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
  MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
  -->

<lv-form [lvLabelColon]="false" [formGroup]="formGroup" class="formGroup">
  <lv-form-item>
    <lv-form-label lvRequired>
      {{title}}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="baseUtilService.requiredErrorTip">
      <lv-select formControlName="platform_telnet" [lvOptions]="telnetOptions" lvValueKey="value" [lvDisabled]="item"
        [ngStyle]="{'width':treeSelection.type === resourceType.OpenStack ? null : i18n.language === 'zh-cn' ? '400px' : '245px'}"
        style="margin-right:5px">
      </lv-select>
      <button lv-button (click)="getTenantOptions()" *ngIf="treeSelection.type !== resourceType.OpenStack">
        {{'protection_hcs_tenant_refresh_label' | i18n}}
      </button>
    </lv-form-control>
  </lv-form-item>
</lv-form>

<lv-form class="form-position">
  <lv-form-item>
    <lv-form-label lvRequired *ngIf="treeSelection.type !== resourceType.OpenStack">
      <span class="node-style">{{managerLabel}}</span>
    </lv-form-label>
    <lv-form-label *ngIf="treeSelection.type === resourceType.OpenStack">
      <span class="node-style aui-gutter-column-md">{{managerLabel}}</span>
    </lv-form-label>
  </lv-form-item>
  <div class="user-add-tips" *ngIf="showTips">
    {{ 'protection_hcs_add_user_tips_label' | i18n }}
  </div>
</lv-form>

<lv-form [lvLabelColon]="false" [formGroup]="formGroup" class="formGroup"
  *ngIf="treeSelection.type === resourceType.OpenStack">
  <lv-form-item>
    <lv-form-label lvRequired>
      {{ 'common_username_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="nameErrorTip">
      <input lv-input type="text" formControlName="username" autocomplete="new-password"
        placeholder="{{'protection_openstack_username_label' | i18n}}" />
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label lvRequired>
      {{ 'common_password_label' | i18n }}
    </lv-form-label>
    <lv-form-control [lvErrorTip]="pwdErrorTip" class="test">
      <aui-inupt-with-eye formControlName="password" placeholder="{{'protection_openstack_password_label' | i18n}}">
      </aui-inupt-with-eye>
    </lv-form-control>
  </lv-form-item>
  <lv-form-item>
    <lv-form-label></lv-form-label>
    <lv-form-control>
      <button lv-button (click)="test()"
        [disabled]="formGroup.get('username').invalid||formGroup.get('password').invalid||formGroup.get('platform_telnet').invalid"
        [lvLoading]="testLoading">
        {{ 'common_test_label' | i18n }}
      </button>
    </lv-form-control>
  </lv-form-item>
</lv-form>


<div class="aui-operation" *ngIf="treeSelection.type !== resourceType.OpenStack">
  <lv-pro-button-group [config]="optItems"></lv-pro-button-group>
</div>

<div class="algin-table" *ngIf="treeSelection.type !== resourceType.OpenStack">
  <lv-pro-table #dataTable [config]="tableConfig" [data]="tableData"></lv-pro-table>
</div>